package labuladong.binaryTree;


class Same_Tree_Solution {

    public boolean isSameTree(TreeNode p, TreeNode q) {
        if (p == null && q == null) {
            return true;
        }
        if  (p == null || q == null){
            return false;
        }
        if (p.val != p.val) {
            return false;
        }

        boolean leftIsTrue = isSameTree(p.left, q.left);

        boolean rightIsTrue = isSameTree(p.right, q.right);


        return leftIsTrue && rightIsTrue;
    }

    void traverse(TreeNode node){
        traverse(node.left);
        traverse(node.right);
    }

}